Page({
  data: {
    dialogVisible: false,
    roomList:[],
    houseId:''
  },
  async onLoad () {
    const res = await wx.http({
      url: '/room'
    })
console.log(res);
    this.setData({roomList:res.data})
  },
  async dialogClose(e){
    if(e.detail === 'confirm'){
      await wx.http({
        url:`/room/${this.houseId}`,
        method:'DELETE'
      })
      const res = await wx.http({url:'/room'})
      this.setData({roomList:res.data})
    }
  },
  swipeClose(ev) {
    const { position, instance } = ev.detail
    console.log(ev);
    if (position === 'right') {
      this.houseId = ev.mark.id
      // 显示 Dialog 对话框
      this.setData({
        dialogVisible: true,
      })
      // swiper-cell 滑块关闭
      instance.close()
    }
  },

  goDetail(e) {
    wx.navigateTo({
      url: '/house_pkg/pages/detail/index?houseId=' + e.mark.id,
    })
    // console.log(e.mark.id);
  },

  addHouse() {
    wx.navigateTo({
      url: '/house_pkg/pages/locate/index',
    })
  },
})
